
package GUI;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

/**
 * This class provides an EmoticonsPanel Panel with buttons on it
 * @author Yaniv Kalif
 * @
 */
public class EmoticonsPanel extends JPanel
{
    ImageIcon[] _Images;//_images Array of EmoticonsPanel Images
    public JButton[] _Buttons;// @param _Buttons Array of JButtons
    public int _size;// _size number of active emoticons
   /**
    * Default Constructor
    * this costructor:
    * * loads the emoticons images/icons to the _Images array
    * * initializing the buttons for each emoticon
    */
    public EmoticonsPanel()
    {
            _size=4;
        //Initializing the images
            _Images = new ImageIcon[_size];
            for(int i=0;i<_size;i++)
             _Images[i]=new ImageIcon();

             _Images[0].setImage(Toolkit.getDefaultToolkit().getImage("Pics/Emoticons/happy.gif"));
             _Images[1].setImage(Toolkit.getDefaultToolkit().getImage("Pics/Emoticons/sad.gif"));
             _Images[2].setImage(Toolkit.getDefaultToolkit().getImage("Pics/Emoticons/wink.png"));
             _Images[3].setImage(Toolkit.getDefaultToolkit().getImage("Pics/Emoticons/angry.gif"));

         //initilizing the Buttons
             _Buttons=new JButton[4];
             _Buttons[0]=new JButton( _Images[0]);
             _Buttons[0].setName("happy");
             _Buttons[1]=new JButton( _Images[1]);
             _Buttons[1].setName("sad");
             _Buttons[2]=new JButton( _Images[2]);
             _Buttons[2].setName("wink");
             _Buttons[3]=new JButton( _Images[3]);
             _Buttons[3].setName("angry");
         //Adding the buttond to the panel
             for(int i=0;i<_size;i++)
             {
                 _Buttons[i].setPreferredSize(new Dimension(20, 20));
                 _Buttons[i].setBorder(new BevelBorder(BevelBorder.RAISED));
                 this.add(_Buttons[i]);
             }

         this.setBorder(new BevelBorder(BevelBorder.RAISED));
    }
//    String CheckEmoticons(String src)
//    {
//        src = src.replace(":-)",(CharSequence) _Images[0]);
//        src = src.replace(":-(",(CharSequence) _Images[1]);
//        src = src.replace(";-)",(CharSequence) _Images[2]);
//        src = src.replace(">:(",(CharSequence) _Images[3]);
//        return src;
//    }

}
